'use strict';

const Service = require('egg').Service;
const qiniu = require('qiniu')

class QiniuService extends Service {
    // 生成七牛token
    async getQiniuToken() {
        const {app} = this
        // 这里需要七牛的Access Key和Secret Key
        let mac = new qiniu.auth.digest.Mac(app.config.qiniu.ak, app.config.qiniu.sk);
        let options = {
            scope: 'lssxhjl',
        };
        let putPolicy = new qiniu.rs.PutPolicy(options);
        let uploadToken = putPolicy.uploadToken(mac);
        return uploadToken
    }
}


module.exports = QiniuService;